from ultralytics import YOLO
if __name__ == '__main__':
    # 加载模型
    model = YOLO(r'D:\yolov8-main\ultralytics\models\v8\yolov8n.yaml')
    # 训练模型
    results = model.train(data=r'D:\yolov8-main\dataset\data.yaml',  
                           cache=False,
                           imgsz=640,
                           epochs=100,
                           single_cls=False,  # 是否是单类别检测
                           batch=8,
                           close_mosaic=10,
                           workers=0,
                           device=0,  # device='cpu',
                           optimizer='SGD',
                           
                           project='runs/train',
                           name='exp',)